package com.broada.apm.logic.impl;

import java.util.List;

import com.broada.apm.base.BaseLogic;
import com.broada.apm.entity.Relation;
import com.broada.apm.entity.convert.BeanConvert;
import com.broada.apm.logic.RelationLogic;

public class RelationLogicImpl  extends BaseLogic implements RelationLogic{

	@Override
	public void saveRelation(Relation rel) {
		com.broada.apm.model.Relation relation = (com.broada.apm.model.Relation) BeanConvert.convertFrontObjToDataObj(rel);
		relationService.addRelation(relation);
	}

	@Override
	public List<Relation> queryRelationByAppId(String appId) {
		List<com.broada.apm.model.Relation> relations = relationService.getRelationByAppId(appId);
		return BeanConvert.convertRelation(relations);
	}

	@Override
	public void deleteRelationByAppId(String appId) {
		relationService.deleteRelationByAppId(appId);
	}

	@Override
	public List<Relation> queryRelationByFromOrTo(String[] serviceIds) {
		List<com.broada.apm.model.Relation> relations = relationService.getRelationByFromOrTo(serviceIds);
		return BeanConvert.convertRelation(relations);
	}

	@Override
	public List<Relation> queryRelationByFromAndTo(String[] fromSerIds,
			String[] toSerIds) {
		List<com.broada.apm.model.Relation> relations = relationService.getRelationByFromAndTo(fromSerIds, toSerIds);
		return BeanConvert.convertRelation(relations);
	}

	@Override
	public void deleteRelationByFromOrTo(String[] nodeIds) {
		relationService.deleteRelationByFromOrTo(nodeIds);
	}
}
